#include "SChar.h"

SCharSp SChar::Parse(string s)
{
	trim(s);

	// Check syntax 
	//   - '.'

	regex reg("'.'");

	if ( !regex_match(s, reg))
	{
		throw SParseException("Syntax error: " + s + " is not a SChar literal.");
	}

	return SChar::Create( s.at(1) );
}

std::string SChar::ToString( string format )
{
	if ( format == "n" )
	{
		return string(1, value);
	}

	return "'" + string(1, value) + "'";
}

SCharSp SChar::Create( char value )
{
	return SCharSp(new SChar(value));
}